# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-net-imap
_gemname=net-imap
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=0.2.3
pkgrel=0
pkgdesc="Ruby client api for Internet Message Access Protocol"
url="https://github.com/ruby/net-imap"
arch="noarch"
license="BSD-2-Clause AND Ruby"
depends="ruby"
checkdepends="ruby-rake ruby-test-unit"
makedepends="ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/net-imap/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare
	sed -i '/require .bundler/d' Rakefile
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnessecary files
	cd "$gemdir"
	rm -rf build_info cache extensions plugins
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
69b6596a8ecc66788be10d11dad911351db6ff651f56e8dc5223f4c948efe0d2e53bd465ebf56edd96f1c414e3819413835c14b35a8e90b9f9ac59bfaa5611c6  net-imap-0.2.3.tar.gz
4185c7402f16425c2c62ac074d0bab7406dcd9dd90d969836274e0599cea479501c402eab0d696cffe2afd5f4663434f13df9867811e2e0b14a5bc565d18ab04  gemspec.patch
"
